print('### init')
empty_list = []
bicycles = ['trek', 'cannondale', 'redline', 'specialized']
print(bicycles)

print('### index')
print(bicycles[0].title())
print(bicycles[2])
print(bicycles[3])
print(bicycles[-1])
print(bicycles[-2])

print('### set item')
print('### 支持了原生array直接操作元素的操作')
motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
motorcycles[0] = 'ducati'
print(motorcycles)

print('### add item')
print('### append')
motorcycles = []
print(motorcycles)
motorcycles.append('honda')
motorcycles.append('yamaha')
motorcycles.append('suzuki')
motorcycles.append('ducati')
print(motorcycles)

print('### insert')
motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
motorcycles.insert(0, 'ducati')
print(motorcycles)

print('### delete')
print('### del command')
motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
del motorcycles[0]
print(motorcycles)

print('### pop without argument')
motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
popped_motorcycle = motorcycles.pop()
print(motorcycles)
print("popped " + popped_motorcycle)

print('### pop with argument 0')
motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
popped_motorcycle = motorcycles.pop(0)
print(motorcycles)
print("popped " + popped_motorcycle)

print('### remove per value')
motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
to_remove_value = 'honda'
motorcycles.remove(to_remove_value)
print(motorcycles)
print("removed " + to_remove_value)

print('### sort')
cars = ['bmw', 'audi', 'toyota', 'subaru']
print(cars)
cars.sort()
print(cars)
cars.sort(reverse=True)
print(cars)

print('### sorted function')
cars = ['bmw', 'audi', 'toyota', 'subaru']
print(cars)
sorted_cars = sorted(cars)
print(sorted_cars)
sorted_cars = sorted(cars, reverse=True)
print(sorted_cars)
print(cars)

print('### reverse')
cars = ['bmw', 'audi', 'toyota', 'subaru']
print(cars)
cars.reverse()
print(cars)

print('### len')
cars = ['bmw', 'audi', 'toyota', 'subaru']
print(cars)
cars_count = len(cars)
print(cars_count)

# print('### index out of scope')
# cars = ['bmw', 'audi', 'toyota', 'subaru']
# print(cars[0])
# print(cars[1])
# print(cars[2])
# print(cars[3])
# print(cars[4])
# print(cars)
#
# cars = []
# print(cars[-1])
# print(cars)

print('### for list ')
magicians = ['alice', 'david', 'carolina']
for magician in magicians:
    print(magician)
    print("I can't wait to see your next trick, " + magician.title())
print("Thank you, everyone. That was a great magic show!")

print('### loop remove list ### ')
pets = ['dog', 'cat', 'dog', 'goldfish', 'cat', 'rabbit', 'cat']
print(pets)
while 'cat' in pets:
    pets.remove('cat')
print(pets)
